<?php
namespace app\branch\controller;
use think\Controller;
use think\Session;
use think\Request;
/**
 * 分公司房车管理
 */
class Caravancontrol extends Controller
{   
    use \app\common\traits\controller\TraitController;
    //登陆与权限判断
    protected $beforeActionList = [
        'checkLogin',
    ];
    protected function checkLogin()
    {
        if (!model('Managers')->checkLogin()) {
            $this->redirect('@manager/login');
            exit;
        }
    }
    //获取子级信息
    // public function getsoninfo($id)
    // {
    //   //['id' => $v['id'] , 'name' => $v['name']]
    //   $result=model("Areas")->where('pid',$id)->select()->toArray();
    //   foreach ($result as $k=> $v) {
    //     $ids[]=['id' => $v['id'] , 'name' => $v['name']];
    //   }
    //   return $ids;
    // }
    /**
     * [getList 房车管理列表]
     * @return [type] [description]
     */
    public function getList()
    {
      //去本公司下的营地
      $lo_bran_id = model('Managers')->getLoginUserInfo('branch_id');
      $campinfos = model('Campcontrols')->where('branch_id',$lo_bran_id)->select();
      $this->assign('campinfos',$campinfos);
      //取本公司下的所有房车
      $list = model('Caravancontrols')->getCaravanList(array_merge(input('get.'),['branch_id'=>$lo_bran_id]));
      return view('caravancontrol/list',['list'=>$list]);
    }
     /**
     * [getReadInfo 查看房车信息]
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public function getReadInfo($id)
    {
        //房车详细信息
        $info = model("Caravancontrols")->getCaravanIofo($id);
        $ziduan1 = model('Caravancontrols')->getZiduan1();
        return view('caravancontrol/caravaninfo',['info'=>$info,'ziduan1'=>$ziduan1]);
    }
}
